package io;

import java.io.*;

public class BufferOutputStreamInputStreamTest {
    public static void main(String[] args) {
        FileInputStream fileInputStream = null;
        BufferedInputStream bufferedInputStream=null;
        BufferedOutputStream bufferedOutputStream=null;
        byte[] bytes = new byte[1024 * 13];
        int count=0;
        try {
           fileInputStream = new FileInputStream("D:/1.jpg");
             bufferedInputStream = new BufferedInputStream(fileInputStream);
            FileOutputStream fileOutputStream = new FileOutputStream("D:/2.jpg");
             bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
             while ((count=bufferedInputStream.read(bytes))!=-1){
                 bufferedOutputStream.write(bytes,0,count);
             }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                bufferedOutputStream.flush();
                bufferedInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
